<?php
require_once('inc/init.php');
require_once('inc/pager.php');
require_once getCacheFilePath('forums.php');

$headtitle="系统积分/用户组/权限";
$action=strFilter($_GET['action']);
switch($action){
	case "":
		$rows_groups=$db->row_select("groups","groupid>0",0,"*","groupid");
		foreach($rows_groups as $key=>$grouprow){
				if(empty($grouprow['groupname'])){
					continue;
				}
				$grouprow['grouptype'] = $grouprow['groupid']>100 ? "<span class=group_system>系统组</span>" : "<span class=group_normal>普通组</span";
				$grouprow['markrange'] = $grouprow['groupid']>100 ? "不受积分限制" : "{$grouprow['marklower']} ~ {$grouprow['markhigher']}";
				$grouprow['starimg']=getStar($grouprow['starnum']);
				$grouprow['popedomlink'] = $grouprow['groupid']>100 ? "": "<a href=\"credits.php?action=popedom&groupid={$grouprow['groupid']}\">点击查看</a>";
				$grouprow['trclass'] =$grouprow['groupid']>100 ? "group0" : "group1";
				$rows_groups[$key]=$grouprow;
		}
		$creditsexp = $cache_settings['creditsexpression'];
		$creditsexp=str_replace(	array('postsnum', 'credits1', 'credits2', 'credits3', 'credits4', 'credits5', 'credits6', 'credits7', 'credits8' ), 
								array('帖数', $cache_credits['credits1']['creditsname'], $cache_credits['credits2']['creditsname'], $cache_credits['credits3']['creditsname'], $cache_credits['credits4']['creditsname'], $cache_credits['credits5']['creditsname'], $cache_credits['credits6']['creditsname'], $cache_credits['credits7']['creditsname'], $cache_credits['credits8']['creditsname']), 
								$creditsexp
							);
		
	break;

	case "popedom":
		$groupid=numFilter($_GET['groupid']);
		
		$p=$cache_groups[$groupid]['popedom'];
		$ps=explode("|",$p);
		
		$pstr=array(
			'0'=>'允许访问论坛',
			'1'=>'阅读权限',
			'2'=>'允许查看用户资料',
			'3'=>'允许发送短信',
			'4'=>'允许使用搜索',
			'5'=>'允许自定义头衔',
			'6'=>'允许发起投票',
			'7'=>'允许发起悬赏',
			'8'=>'',
			'9'=>'允许发新帖',
			'10'=>'允许发表回复',
			'11'=>'允许直接发帖',
			'12'=>'',
			'13'=>'允许下载/查看附件',
			'14'=>'允许上传附件',
			'15'=>'最大附件尺寸:(KB)',
			'16'=>'每天最多附件数量(个)',
			'17'=>'允许附件类型'
		);
		
		$popedoms=array(
			'0'=>array('<span class=noallow>X</span>', '<span class=allow>√</span>'),
			'1'=>array('<span class=noallow>X</span>', '<span class=allow>√</span>'),
			'2'=>array('<span class=noallow>X</span>', '<span class=allow>√</span>'),
			'3'=>array('<span class=noallow>X</span>', '<span class=allow>√</span>'),
			'4'=>array('<span class=noallow>X</span>', '<span class=allow>允许搜索标题/作者</span>', '<span class=allow>允许全文搜索</span>'),
			'5'=>array('<span class=noallow>X</span>', '<span class=allow>√</span>'),
			'6'=>array('<span class=noallow>X</span>', '<span class=allow>√</span>'),
			'7'=>array('<span class=noallow>X</span>', '<span class=allow>√</span>'),
			'8'=>array('<span class=noallow>X</span>', '<span class=allow>√</span>'),
			'9'=>array('<span class=noallow>X</span>', '<span class=allow>√</span>'),
			'10'=>array('<span class=noallow>X</span>', '<span class=allow>√</span>'),
			'11'=>array('<span class=allow>根据版块设置</span>', '<span class=allow>需要审核</span>', '<span class=allow>不需要审核</span>'),
			'12'=>array('<span class=noallow>X</span>', '<span class=allow>√</span>'),
			'13'=>array('<span class=noallow>X</span>', '<span class=allow>√</span>'),
			'14'=>array('<span class=noallow>X</span>', '<span class=allow>√</span>'),
			'15'=>array('<span class=allow>'.$ps[15].'</span>'),
			'16'=>array('<span class=allow>'.$ps[16].'</span>'),
			'17'=>array('<span class=allow>'.$ps[17].'</span>')
		);
		
		foreach($ps as $key=>$psitem){
			if($key>14){
				$psitem=0;
			}
			$ps[$key]=$popedoms[$key][$psitem];
		}
		
	break;
}

require_once('header.php');
require_once getTemplatePath('credits.htm');
footer();
?>